package com.polaris.live.adapter

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterOtherGameTypeBinding
import com.polaris.live.resp.back_resp.LivePartyGamePriceVo
import com.polaris.live.utils.CommonUtils

/**
 * OtherGameTypeAdapter
 *
 * @author Created by 半仙 on 2024/3/19/019 21:45
 */
class OtherGameTypeAdapter :
    BaseBindingAdapter<AdapterOtherGameTypeBinding, LivePartyGamePriceVo>() {

    private var mSelectPosition = 0

    override fun convert(
        holder: VBViewHolder<AdapterOtherGameTypeBinding>,
        item: LivePartyGamePriceVo,
    ) {
        holder.vb.apply {
            val position = holder.absoluteAdapterPosition
            if (mSelectPosition == position) {
                root.alpha = 1.0f
            } else {
                root.alpha = 0.4f
            }

            if (position == data.size - 1) {
                viewPleaseHolder.visibility = View.GONE
            } else {
                viewPleaseHolder.visibility = View.VISIBLE
            }
            tvTypeRewardName.text = item.name
            ivGameTypeCoin.setImageResource(CommonUtils.invokeGameHomeRoundIcon(item.assetType))
        }
    }

    fun setSelectPosition(position: Int) {
        mSelectPosition = position
        notifyDataSetChanged()
    }

    fun getSelectItem() = data[mSelectPosition]

}